﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;

using DataAccess;
using Entities;
using Common;

namespace BusinessLogic
{
    public static class HangHoaGoiHang
    {
        public static Entities.HienThi_ChiTiet_DonDatHang Select(string mahang)
        {
            Entities.HienThi_ChiTiet_DonDatHang data = null;
            try
            {
                Entities.GoiHang[] goi = BusinessLogic.GoiHang.Select();
                Entities.HangHoa[] hanghoa = BusinessLogic.HangHoa.SelectHangHoa();
                if (goi != null)
                {
                    for (int k = 0; k < goi.Length; k++)
                    {
                        data.MaHangHoa = goi[k].MaGoiHang;
                        data.TenHangHoa = goi[k].TenGoiHang;
                        data.SoLuongDat = 1;
                        data.GiaGoc = goi[k].GiaNhap;
                        data.GiaNhap = goi[k].GiaNhap;
                        data.Giabanbuon = goi[k].GiaBanBuon;
                        data.Giabanle = goi[k].GiaBanLe;
                        data.PhanTramChietKhau = "0";
                        data.Thuegiatrigiatang = "0";
                        data.ChietKhau = "0";
                        break;
                    }
                }
                if (hanghoa != null)
                {
                    for (int k = 0; k < hanghoa.Length; k++)
                    {
                        data.MaHangHoa = hanghoa[k].MaHangHoa;
                        data.TenHangHoa = hanghoa[k].TenHangHoa;
                        data.SoLuongDat = 1;
                        data.GiaGoc = hanghoa[k].GiaNhap;
                        data.GiaNhap = hanghoa[k].GiaNhap;
                        data.Giabanbuon = hanghoa[k].GiaBanBuon;
                        data.Giabanle = hanghoa[k].GiaBanLe;
                        data.PhanTramChietKhau = "0";
                        data.Thuegiatrigiatang = hanghoa[k].GiaTriThue;
                        data.ChietKhau = "0";
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                data = null;
            }
            return data;
        }
    }
}
